#ifndef STRINGUTILS_H
#define STRINGUTILS_H

#include <string>
extern "C"{
#include <libavcodec/avcodec.h>
}

template<class... T>
std::string format(const char *fmt, const T&...t)
{
    const auto len = snprintf(nullptr, 0, fmt, t...);
    std::string r;
    r.resize(static_cast<size_t>(len) + 1);
    snprintf(&r.front(), len + 1, fmt, t...);  // Bad boy
    r.resize(static_cast<size_t>(len));

    return r;
}

static inline char * av_err2str2(int errnum)
{
     static char tmp[256] = {0};
      av_strerror(errnum, tmp, 256);
      return tmp;
}

#endif // STRINGUTILS_H
